package com.sg.business.model.dataset.project;

import com.mongodb.BasicDBObject;
import com.sg.business.model.IModelConstants;
import com.sg.business.model.Project;
import com.sg.business.model.Work;
import com.sg.widgets.commons.dataset.MasterDetailDataSetFactory;

public class RelatedWorkOfProject extends MasterDetailDataSetFactory {

	public RelatedWorkOfProject() {
		super(IModelConstants.DB, IModelConstants.C_WORK);
	}

	@Override
	protected String getDetailCollectionKey() {
		return Work.F__ID;
	}

	@Override
	protected Object getMasterValue() {
		if (master != null) {
			if (master instanceof Project) {
				return new BasicDBObject().append("$in",
						((Project) master).getRelatedWorkId());
			}
		}
		return super.getMasterValue();
	}

}
